<!DOCTYPE html>
<html lang="en">
<head>
[#include "/customer/include/static.htm"]
<link href="${path}/resources/plug/layui/css/layui.css" rel="stylesheet" type="text/css"/>
<script src="${path}/resources/plug/layui/layui.js" type="text/javascript"></script>
<link href="${path }/resources/css/tender.css" rel="stylesheet" type="text/css" />
</head>
<body>

<!--头部-->
[#include "/customer/include/header.ftl"]
<div class="inv_mian">
	<!--invs_info-->
	<div class="section section_top clearfix">
		<div class="section_top_l fl">
			<div class="section_top_title cleafix">
				<p class="fl">${borrow.name }
				</p>
				[  <em class="type xin" style="font-size: 20px"> ${p2p_borrow_type( borrow.loan_category)}</em>]
			</div>
			<div class="sec_info_inner">
				<ul class="sec_list">
					<li class="li_w1">
						<h4>借款金额</h4> <b>${currency(borrow.account) } </b>
					</li>
					<li class="li_w2">
						<h4>投资周期</h4>
						<b>
							${borrow.time_limit }

							[#if borrow.is_day==1 ]
								天
							[#else]
								个月
							[/#if]
						</b>
					</li>
					<li class="li_w3">
						<h4>预期年利率</h4> <b>${borrow.apr }%
					</li>
				</ul>
				<div class="ul_box">
					<ul>
						<li>还款方式： ${p2p_get_dict("borrow_style",borrow.pay_style)} </li>
						<li>项目奖励:
							<font>
							[#if borrow.radio_account gt 0]
								${borrow.radio_account}%
							[#else]
                                无
							[/#if]
							</font>
						</li>
						<li>还款时间：
							[#if borrow.loan_category==10 ]
								满额就还
							[#else]
								满标后
								<font>
									${borrow.time_limit }
									[#if borrow.is_day==1 ]
										天
									[#else]
										个月
									[/#if]
								</font>
							[/#if]
						</li>
						<li>违约保障类型：<font>本息保障</font></li>
						<li>是否秒标:<font>[#if borrow.loan_category==10]是[#else]否[/#if]</font></li>
						<li>要求待收：<font>${borrow.lowest_wait_account}</font></li>
					</ul>
				</div>
			</div>
		</div>
		<style>
		#jbrowse ul li{
			float:left
		}
.span {
	display: block;
	width: 64px;
	height: 64px;
	text-align: center;
	font-size: 22px;
	line-height: 64px;
	position: absolute;
	top: 115px;
	left: 90px;
	color: #e97676;
}
</style>
		<div class="section_top_r fr">
			<div class="section_top_inner clearfix">
				<div id="" class="progress_l fl">
					<div class="prod-je fl" style="margin-left: 25px;">
						<h3>投资进度</h3>

						<div class="progressinvest">
							<span class="span" style="margin-top:20px;">${(borrow.amount_invested/borrow.account*100)?int}%</span>
						</div>

						<div
							style="clear: both; position: absolute; top: 260px; left: 80px;">
							<li>可投金额
								<p>
									<font>${currency(borrow.account-borrow.amount_invested) }元</font>
							</li>
						</div>
					</div>
				</div>
				<div></div>
				<div class="tan1 none" id="closelocalbox3">
					<div class="top-right-content fr no-yuyue">
						<div class="left-time">
							<span>募集剩余时间：</span>
							[#if borrow.status==3 ]
								<font class="endtime">${borrow.end_time }</font>
							[#elseif borrow.status lt 3 && borrow.status gte 0]
								<font>未开始</font>
							[#else]
								<font>已结束</font>
							[/#if]
						</div>
						<p class="ketou">
							<span>最小投资金额：</span><font>${borrow.min_account }</font>元
						</p>
						<p class="keyong">
							<span>最大投资金额：</span><font>${borrow.max_account }</font>元
						</p>
						<p class="keyong">
							<span>我的账户余额：</span>
							[#if loginUser !=null ]
									<font>${account.balance }</font>元
							[#else]
									<font>[<a href="${path }/login">请先登录</a>]
									</font>
							[/#if]
						</p>


						<form class="layui-form">
                            <input type="hidden" value="${borrow.id }" id="loanId" name="loanId"/>
                            <input type="hidden" value="${token }" name="token"/>
							<div class="layui-input-inline" style="width: 280px;margin-top:3px;">
								<input type="text" name="account" maxlength="9" required  lay-verify="required" placeholder="请输入投资金额" autocomplete="off" class="layui-input">
							</div>


							<div class="layui-input-inline" style="width: 280px;margin-top:3px;">
								<input type="password" name="payPassword" required  lay-verify="required" placeholder="请输入支付密码" autocomplete="off" class="layui-input">
							</div>

						[#if borrow?? && borrow.tbpwd?? && borrow.tbpwd != '']
							<div class="layui-input-inline" style="width: 280px;margin-top:3px;">
								<input type="password" name="tbpwd"  required  lay-verify="required" placeholder="请输入定向密码" autocomplete="off" class="layui-input">
							</div>
						[/#if]

							<div class="layui-input-inline">
								<button lay-submit lay-filter="MainForm" [#if borrow.status gt 3 ]disabled="disabled" class="layui-btn layui-btn-disabled"[#else]class="layui-btn" [/#if] style="width: 280px;margin-top:3px;">确 认 投 资</button>
							</div>
						</form>

					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- section1结束 -->

	<!--invs_con-->
	<div class="section section_midden">
		<div class="tou_list_tab clearfix">
			<h3>投标详情</h3>
			<ul class="inv_tit" id="invd_con_tit">
				<!-- <li class="sel"><a href="javascript:;">项目推介意见</a></li> -->
				<li class="sel"><a href="javascript:;">项目介绍</a></li>
				<!-- 	<li><a href="javascript:;">风控信息</a></li> -->
				<li><a href="javascript:;">投标记录</a></li>
				<li><a href="javascript:;">项目图片</a></li>
			</ul>
		</div>

		<div class="invd_model">${borrow.content }</div>

		<div class="invd_model hidden">
			<table>
				<tr>
					<th>序号</th>
					<th>用户名</th>
					[#if Session.adminUser??]
						<th>姓名</th>
					[/#if]

					<th>年利率</th>
					<th>预投金额</th>
                    <th>成功金额</th>
					<th>投标方式</th>
					<th>投标时间</th>
				</tr>
				[@p2p_loan_tender_list borrowId = borrow.id]
				[#list tag_list as borrowTender]
					<tr>
						<td>${borrowTender_index+1 }</td>
						[#if Session.adminUser?? ]
							<td>${borrowTender.username}</td>
						[#else]
                        	<td>*${borrowTender.username?substring(0,3)}**</td>
						[/#if]
						[#if Session.adminUser??]
							<td>${borrowTender.real_name}</td>
						[/#if]
						<td>${borrow.apr}%</td>
                        <td>￥${borrowTender.pre_tender_money}</td>
						<td>￥${borrowTender.success_money }</td>
						<td>
							[#if borrowTender.is_auto==0]
      								手动投标
							[#elseif borrowTender.is_auto==1]
      								自动投标
							[/#if]
						</td>
						<td>${p2p_date_format(borrowTender.addtime,"yyyy-MM-dd HH:mm:ss") }</td>
					</tr>
				[/#list]
				[/@p2p_loan_tender_list]
			</table>
		</div>
		<div class="invd_model hidden" id="jbrowse">
			<ul>
				[@p2p_loan_img borrowId = borrow.id]
					[#list tag_list as img]
						<li><img src="${img.img}" alt="" width="150px" /></li>
					[/#list]
				[/@p2p_loan_img]
			</ul>
		</div>
		<!--invs_con end-->



	</div>
</div>
<script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form(), $=layui.jquery, layer = layui.layer;

        form.on('submit(MainForm)', function(data){

            var lowest = Number('${borrow.min_account}');
            var balance = Number('${account.balance}');

            if (balance <  data.field.account  ||  balance<=0) {
                layer.msg("您的余额不足，请充值");
                return false;
            }

            if (data.field.account < lowest && lowest > 0) {
                layer.msg("投标金额不能低于最小限额" + lowest + "元");
                return false;
            }

            var index = layer.load();
            ajax({
                url:"${path}/loan/tender",
                data: data.field,
                success: function(result){
                    if (result.type == "success") {
                        layer.msg(result.content,function(){  location.href ="${path}/loan/${borrow.id}"; });
                    } else {
                        layer.msg(result.content,{icon:2});
                    }
                    layer.close(index);
                },
                complete:function(){
                    layer.close(index);
                }
            });
            return false;
        });
    });
</script>
[#include "/customer/include/footer.ftl"]

</body>
</html>